<template>
  <view>
    <view class="back-color">
      <view class="result-top">
        <text>结果分析</text>
        <text>本测试及结果由AI得出,仅供参考,不能作为诊断及诊疗的依据</text>
      </view>
      <view class="result-desc">
        <view>{{list.scope}}：{{list.result}}</view>
        <view>{{list.suggest}}</view>
        <view class="bold">测评结果概述:</view>
        <view class="bold">1,{{list.outline[0]}}</view>
        <view class="bold">2,{{list.outline[1]}}:</view>
        <view></view>
        <block>
          <view class="bold">AI为你推荐以下科室</view>
          <view class="recommend" v-for="(item,index) in list.recommend" :key="index">
            <label>
              <text class="bold">{{item.dep_name}}</text>
              <text class="Hosp">{{item.hospital}}</text>
            </label>
            <label class="regi" @click="go1(item.dep_id)">去挂号</label>
          </view>
        </block>
      </view>
    </view>
    <!-- 按钮 -->
    <view class="exceed"></view>
    <view class="submit">
      <button plain="true" open-type="share">邀请朋友测一测</button>
      <button plain="true" @click="go">再测一次</button>
    </view>
  </view>
</template>

<script>
import {depression, insomnia, premature} from "../../utils/API/homeapi";
import {TEST} from "../../utils/test";
export default {
  data() {
    return {
      arr: null,
      title: null,
      list: {}
    };
  },
  onLoad(o) {

    this.title = o.title
    this.xuan(o.arr)
    console.log(this.title)
  },
  onshow() {
    this.xuan()
  },
  methods: {
    async xuan(arr) {
      if (this.title === '0') {
        let {data} = await depression({value: arr.split(",")})

        this.list = data[0];
        console.log(this.list)
      }
      if (this.title === '1') {
        let {data} = await premature({value: arr.split(",")})
        this.list = data[0];
      }
      if (this.title === '2') {
        let {data} = await insomnia({value: arr.split(",")})
        this.list = data[0];
      }
    },
    go() {
      wx.navigateBack({
        delta: 1
      })
    },
    go1(id){
      wx.navigateTo({
        url:"/pages/doctorList/doctorList?id="+id
      })
    }
  },
  //转发朋友
  onShareAppMessage() {
    const a = TEST.filter(item => {
      return item.type === this.title
    })
    return {
      title: a[0].name,
      path: a[0].share_path,
      imageUrl: a[0].share_url
    }
  },
  //转发朋友圈
  onShareTimeline() {
    const a = TEST.filter(item => {
      return item.type === this.title
    })
    return {
      title: a[0].name,
      path: a[0].share_path,
      imageUrl: a[0].share_url
    }
  }
}
</script>

<style lang="scss">
@import url('../../static/common-style/form.css');

page {
  background: #f0f5f9;
}

.back-color {
  background: -webkit-linear-gradient(top, #d6e8ff 30%, #f2f7fb 55%, #f0f5f9 90%);
}

.result-top {
  display: flex;
  flex-direction: column;
  padding: 20rpx;
}

.result-top text:nth-child(1) {
  font-size: 35rpx;
  font-weight: bold;
  padding-bottom: 20rpx;
}

.result-desc {
  background-color: #ffffff;
  border-radius: 10rpx;
  margin: 20rpx;
  padding: 20rpx;
}

.result-desc view {
  margin-bottom: 20rpx;
  line-height: 1.5;
}

.result-desc view:nth-child(1) {
  font-size: 40rpx;
  font-weight: bold;
  color: #0d7cff;
}

.result-desc view:nth-child(2) {
  color: #0d7cff;
}

.bold {
  font-weight: bold;
  display: block;
}

.recommend {
  background-color: #f4f7fa;
  border-radius: 10rpx;
  padding: 30rpx 20rpx;
  display: flex;
  justify-content: space-between;
}

.Hosp {
  color: #bac5cc;
}

.regi {
  align-self: center;
  background-color: #0176ff;
  color: #ffffff;
  padding: 10rpx 20rpx;
  border-radius: 10rpx;
}

.exceed {
  height: 300rpx;
  background: #f0f5f9;
}
</style>
